package cc.inik.goodsquery;

import com.nle.mylibrary.forUse.rfid.RFID;
import com.nle.mylibrary.forUse.rfid.RFIDReadListener;
import com.nle.mylibrary.forUse.rfid.RFIDWriteListener;
import com.nle.mylibrary.forUse.rfid.SingleEpcListener;
import com.nle.mylibrary.transfer.DataBusFactory;
public class RFIDInit {

    public RFID rfid;
    //获取RFID对象
    public RFIDInit(int COMid,int BaudSpeed){
        this.rfid = new RFID(DataBusFactory.newSerialDataBus(COMid, BaudSpeed));
    }
    //获取卡号
    public void getEpc(SingleEpcListener singleEpcListener) throws Exception {
        this.rfid.readSingleEpc(singleEpcListener);
    }
    //写入数据
    public void writeData(String data, RFIDWriteListener rfidWriteListener) throws Exception {
        this.rfid.writeData(data,rfidWriteListener);
    }
    //读取数据
    public void readData(RFIDReadListener rfidReadListener) throws Exception {
        this.rfid.readData(rfidReadListener);
    }
    //关闭链接
    public void rfidClose(){
        this.rfid.stopConnect();
    }

}
